package com.gs.api.projects.bzapplets.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gs.api.projects.bzapplets.dao.BzConfigDao;
import com.gs.api.projects.bzapplets.entity.BzConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author guoyunfei on 2021/7/9 14:03
 * @className BzConfigDao
 * @description TODO
 * @Version 1.0
 */
@Service
public class BzConfigService extends ServiceImpl<BzConfigDao,BzConfig> {

    @Autowired
    private BzConfigDao bzConfigDao;


    public List<BzConfig> getConfig(String type){

        QueryWrapper<BzConfig> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("enable",1);
        queryWrapper.eq("type",type);
        return bzConfigDao.selectList(queryWrapper);
    }

    public BzConfig getOne(String type){
        BzConfig one = bzConfigDao.getOne(type);
        if(null == one){
            return null;
        }
        return one;
    }

    public String getOneValue(String type){
        BzConfig one = bzConfigDao.getOne(type);
        if(null == one){
            return null;
        }
        return one.getValue();
    }

}
